import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import 'element-plus/es/components/message/style/css'
import { toLogin, getTokenByCode } from './utils/login'
const app = createApp(App)
app.use(router)
app.use(createPinia())

function init() {
  const code = new URLSearchParams(location.search).get('code')
  if (code) {
    getTokenByCode(code).then(() => {
      app.mount('#app')
    })
    return
  }
  if (localStorage.gitee_access_token) {
    app.mount('#app')
    return
  }
  toLogin()
}
init()
